package com.itheima.controller;

import com.heima.model.behavior.dtos.LikesBehaviorDto;
import com.heima.model.behavior.dtos.ReadBehaviorDto;
import com.heima.model.behavior.dtos.UnLikesBehaviorDto;
import com.heima.model.common.dtos.ResponseResult;
import com.itheima.service.BehaviorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yunfei
 * @date 2022年10月25日 11:56
 */

@RestController
@RequestMapping("/api/v1")
public class BehaviorController {

    @Autowired
    private BehaviorService behaviorService;

    /**
     * 对文章点赞/取消点赞
     *
     * @param dto
     * @return
     */
    @PostMapping("likes_behavior")
    public ResponseResult like(@RequestBody LikesBehaviorDto dto) {
        return behaviorService.like(dto);
    }

    /**
     * 浏览文章
     *
     * @param dto
     * @return
     */
    @PostMapping("read_behavior")
    public ResponseResult readBehavior(@RequestBody ReadBehaviorDto dto) {
        return behaviorService.readBehavior(dto);
    }

    /**
     * 对文章不喜欢
     *
     * @param dto
     * @return
     */
    @PostMapping("un_likes_behavior")
    public ResponseResult unLike(@RequestBody UnLikesBehaviorDto dto) {
        return behaviorService.unLike(dto);
    }
}
